﻿@model Model.AppUserList
@{
    ViewBag.Title = "EstimateProductionInfo";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model


@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();
            $("#startDate").datebox("setValue", strDate);
            $("#endDate").datebox("setValue", strDate);

            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-exporter", function () {
            ExporterExcel();
        });

        HandleDom.ClassTriggerClick("icon-reload", function () {
      
        });

        HandleDom.ClassTriggerClick("icon-alledit", function () {
            var txtBatchno = $('#txtDBBCBATCHNO').val();
            if (txtBatchno == "") {
                layer.msg("批量审核必须输入批次号", 1);
            } else {
                HandleRequest.submitForm('query', '@Url.Action("UpdateEstimateStatus", "EstimateProductionInfo")', function (data) {
                    eval('data=' + data);
                    if (data.success == true) {
                        layer.alert('执行成功!', 9);
                        InitGrid();
                        HandleDialog.CloseDialog('dlg');
                    } else {
                        layer.alert(data.msg, 3);
                    }
                });
            }


        });

        //初始化数据
        function InitGrid() {
            var txtBatchno = $('#txtDBBCBATCHNO').val();
            var startDate = $('#startDate').datebox('getValue');
            var endDate = $('#endDate').datebox('getValue');
            queryParams = {
                importBatch: txtBatchno,
                startDate: startDate,
                endDate: endDate
            }
            HandleData.InitDataGrid('dg', '/EstimateProductionInfo/InitJsonResult', 'toolbar', queryParams, 'LMEID', false, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
        //导出预估生产单
        function ExporterExcel() {
            var form = $('#import');
            var importBatch = $.trim($("#txtDBBCBATCHNO").attr("value"));
            var startDate = $('#startDate').datebox('getValue');
            var endDate = $('#endDate').datebox('getValue');
            form.form('submit', {
                url: '@Url.Content("~/EstimateProductionInfo/ExporterExcel")' + "?importBatch=" + importBatch + "&startDate=" + startDate + "&endDate=" + endDate,
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        layer.alert('导出成功!', 9);
                    } else {
                        layer.alert(data.msg, 3);
                    }
                }
            });
            }
            //导入预估生产单
            function ImpotExcel() {
                var form = $('#import');
                var dispatchingType = $("#selType  option:selected").val();
                form.form('submit', {
                    url: '@Url.Content("~/EstimateProductionInfo/ImportEstimateProductionInfo")' + "?dispatchingType=" + dispatchingType,
                    success: function (data) {
                        eval('data=' + data);
                        if (data.success) {
                            $("#txtDBBCBATCHNO").val(data.batch);
                            layer.alert('导入成功!', 9);
                            $('#btnExecl').show();
                            InitGrid();
                        } else {
                            layer.alert(data.msg, 3);
                        }
                    }
                });
            }

            //匹配订单数量
            function matchingOrderNumber(type) {
                var form = $('#import');
                var importBatch = $.trim($("#txtDBBCBATCHNO").attr("value"));
                if (importBatch == "") {
                    layer.msg("匹配订单数量必须输入批次号！", 1);
                    return false;
                }
                form.form('submit', {
                    url: '@Url.Content("~/EstimateProductionInfo/MatchingEstimateProductionInfo")' + "?importBatch=" + importBatch + "&type=" + type,
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        $("#txtDBBCBATCHNO").val(data.batch);
                        layer.alert('匹配成功!', 9);
                        $('#btnExecl').show();
                        InitGrid();
                    } else {
                        layer.alert(data.msg, 3);
                    }
                }
            });
            }

    </script>
}
<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>批次号:
                    </td>
                    <td>
                        <input id="txtDBBCBATCHNO" name="txtDBBCBATCHNO" style="width: 154px" validtype="integer['#txtDBBCBATCHNO']" />
                    </td>
                    <td>导入时间:
                    </td>
                    <td>
                        <input class="easyui-datebox" id="startDate" name="startDate" style="width: 140px;" />
                    </td>
                    <td>~：
                    </td>
                    <td>
                        <input class="easyui-datebox" id="endDate" name="endDate" style="width: 140px;" validtype="compareDate['#startDate']" />
                    </td>
                    <td></td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid();">查询</a>

                    </td>

                </tr>
            </table>
        </form>
        <form id="import" method="post" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>配送类型:
                    </td>
                    <td>
                        <select id="selType" name="selType">
                            <option value="0">无</option>
                            <option value="1">当日达</option>
                            <option value="2">次日达</option>
                        </select>
                    </td>
                    <td>
                        <input id="FileUpload" type="file" name="files" style="width: 250px; height: 24px; background: White"
                            class="easyui-validatebox" />
                        <a id="btnGet" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="ImpotExcel()">导入</a>
                    </td>
                    <td><a id="btnDRD" href="#" class="easyui-linkbutton" onclick="matchingOrderNumber(1)">匹配当日达订单</a></td>
                    <td><a id="btnCRD" href="#" class="easyui-linkbutton" onclick="matchingOrderNumber(2)">匹配次日达订单</a></td>
                </tr>
            </table>
        </form>

    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="箱码管理" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'LMEID',width:50">序号</th>
                    <th data-options="field:'GOODSCODE',width:100">货号</th>
                    <th data-options="field:'GOODSNAME',width:180">半成品名</th>
                    <th data-options="field:'DISPATCHINGTYPE',width:80">配送类型</th>
                    <th data-options="field:'ESTIMATENUMBER',width:80">预估数量</th>
                    <th data-options="field:'ORDERNUMBER',width:80">订单数量</th>
                    <th data-options="field:'UPDATENUMBER',width:80">修改数量</th>
                    <th data-options="field:'ACTUALNUMBER',width:80">差异数量</th>
                    <th data-options="field:'IMPORTBATCH',width:100">导入批次</th>
                    <th data-options="field:'STATUS',width:80">状态</th>
                    <th data-options="field:'ESTIMATEDATE',width:100">预估时间</th>
                    <th data-options="field:'CREATEDATE',width:100">创建时间</th>
                </tr>
            </thead>
        </table>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =false },
              new FunctionModule(){Name = "Edit",IsEnable =false },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =true },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =true },
              new FunctionModule(){Name = "AllEdit",IsEnable =true },
              
            }
        }
    }
})

</body>

